# Maintainer: T.J. Townsend <blakkheim@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Christopher Bayliss <christopher.j.bayliss@gmail.com>
# Contributor: Albert De La Fuente Vigliotti
# Contributor: Stefan Husmann <stefan-husmann@t-online.de>
# Contributor: vonpupp

pkgname=xiphos
pkgver=4.2.1
pkgrel=11
pkgdesc='A Bible study tool for GTK3'
arch=('loong64' 'x86_64')
url='https://xiphos.org'
license=('GPL2')
depends=('biblesync' 'dbus-glib' 'icu' 'libbiblesync.so' 'libicui18n.so'
         'minizip' 'sword>=1.9.0' 'webkit2gtk')
makedepends=('appstream-glib' 'cmake' 'docbook-utils' 'gnome-common' 'gtkmm'
             'intltool' 'libffi' 'libxml2' 'python' 'zlib' 'zip')
source=("https://github.com/crosswire/$pkgname/releases/download/$pkgver/$pkgname-$pkgver.tar.xz"
        "https-by-default.patch"
        "xiphos-glibc.patch"
        "disable-webkit-editor.patch")
sha256sums=('d34353f62224302c924757fca55ff0fc19f96815f20b893279ceef3d7d054128'
            '3630dee5f9f05600e1a726b91a89e2eb17615a73d30548de303e7b29ec2286d2'
            'd1669dced24a5d6d9a76ab033fc89201855285b76a1e80ef3fe695242d1c401d'
            'b8e7e8da6eaa246f7f6ff952bf4b5bc87a7274a6e71ae311fad55da2c43aa5af')

prepare() {
  cd "$pkgname-$pkgver"
  # https://github.com/crosswire/xiphos/issues/1083
  patch -Np0 -i ../xiphos-glibc.patch
  # disable study pad as it requires a very old webkitgtk
  # https://github.com/crosswire/xiphos/issues/794
  patch -Np1 -i ../disable-webkit-editor.patch
  # avoid fetching modules over plaintext ftp
  patch -Np1 -i ../https-by-default.patch
}

build() {
  cmake -B build -S "$pkgname-$pkgver" \
      -DCMAKE_BUILD_TYPE=None \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -Wno-dev
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build
}
